Skip to content

fix(routing): back off first-content exploration after failed explorations - #1270

Closed
brandon-eigenlabs wants to merge 2 commits into
Layr-Labs:masterfrom
brandon-eigenlabs:fix/first-content-exploration-backoff
Closed

brandon-eigenlabs wants to merge 2 commits into
Layr-Labs:masterfrom
brandon-eigenlabs:fix/first-content-exploration-backoff

Conversation

@brandon-eigenlabs

@brandon-eigenlabs brandon-eigenlabs commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1254. Evidence exploration admits an idle provider without current performance evidence and prices it at the fleet median. Three things combine so that a degraded provider can keep winning explorations it cannot serve:

  1. Its evidence keeps going away. Idle providers clear their measured decode rate routinely (a typical 0.9.11 provider does so about 3 times an hour), so a genuinely slow provider becomes explorable again and again.
  2. It looks like a median machine. With no measurement, resolveEffectiveTPS falls back to the fleet median, so a 10 tok/s box is priced like a normal one and wins unique_min.
  3. No tracker sees its failures. A first-content timeout surfaces as a 429, which providerOutcomeIsFault deliberately ignores. deadline_unreachable is health-neutral by design. So the node-health breaker, ejection and reputation never react.

Production case (read replica, 2026-09-30, aggregates only): an M3 Max (48 GB, 40-core GPU) on 0.9.11 reported decode at 10–12 tok/s against an M3-family median of 92 (0.11×), and isolated prefill at 80–160 against ~1,200. Its decode evidence cleared about 4 times an hour (normal: fleet median ~3/h), and its slot reported a state outside the known set (folded to other) about 12 times an hour (fleet p90 under 1/h). It stayed eligible throughout, with no breaker, cooldown, ejection or wedge_suspected. In the profiler's 11–33% sample it was selected about once a minute for 90+ minutes. It served only short prompts (5–10 s to first content, against 0.5–4 s forecasts) and timed out on everything over ~1,650 prompt tokens. It produced 19 of the 29 explorable first_chunk_timeouts for gemma between 03:00 and 06:00Z.

Change

Two per-identity checks. Both are scoped to exploration only.

  • Outcome backoff. The reservation commit records whether the winner was selected through the idle exception (PendingRequest.SetFirstContentExplored). That attempt's outcome then feeds back:

    • Failures: first_chunk_timeout (at cancelDispatchForFirstContentTimeout), deadline_unreachable, and a genuine fault (the breaker's own providerOutcomeIsFault, after all neutral, drain and typed-cause gates). Each doubles a per-model suppression interval, from 5 min up to 2 h.
    • Successes: a delivered request halves it.
    • Not counted: capacity sheds, neutral terminal causes and client-shaped outcomes.

    Reset-on-success, as the breaker uses, would not stop this provider, because it still completes short prompts.

  • Remembered decode rate. The heartbeat records each newly measured decode rate per model. The record lives beyond evidence clearing and reconnects. When the median of at least 5 recent observations is below 0.25× the (model, chip family) tpsRegistry median, the provider is not explorable.

Where the state lives. Both are stored as one per-model map on the stable-identity gate (gateFlagExploration, with the lock-free fast path). They are merged on identity migration (stricter state wins), swept after 6 h, and cleared by a provider version change (noteIdentityVersionLocked). The snapshot copies the view, and firstContentEvidenceExplorable checks it, so the scan, retained-plan and commit re-check paths all agree.

Neither is a quarantine. A suppressed provider keeps ordinary feasible-first behaviour and is still selected when no candidate is feasible. Deadline refusals and first-content timeouts remain neutral for every health breaker; a test pins that.

Before

flowchart TD
  A["Idle, genuinely slow provider"] --> B["Evidence cleared<br/>(routine, ~3/h)"]
  B --> C["firstContentEvidenceExplorable: yes<br/>priced at fleet median"]
  C --> D["Wins exploration<br/>(unique_min)"]
  D --> E["first_chunk_timeout (429)"]
  E --> F["providerOutcomeIsFault: 429 ignored<br/>no breaker, no ejection"]
  F --> B
  classDef input fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef check fill:#fef3c7,stroke:#d97706,color:#451a03
  classDef problem fill:#fee2e2,stroke:#dc2626,color:#450a0a
  class A input
  class C check
  class B,D,E,F problem
Loading

After

flowchart TD
  A["Idle, genuinely slow provider"] --> C{"firstContentEvidenceExplorable"}
  C -->|"suppressed or<br/>remembered slow"| N["Not explorable<br/>feasible-first unchanged"]
  C -->|"otherwise"| D["Wins exploration<br/>SetFirstContentExplored(true)"]
  D -->|"timeout / refusal / fault"| X["RecordFirstContentExplorationOutcome(false)<br/>backoff doubles"]
  D -->|"delivered"| Y["RecordFirstContentExplorationOutcome(true)<br/>backoff halves"]
  H["Heartbeat: new decode rate"] --> M["Remembered rates on gate<br/>median of ≥5 vs 0.25× family median"]
  X --> C
  Y --> C
  M --> C
  classDef input fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef check fill:#fef3c7,stroke:#d97706,color:#451a03
  classDef outcome fill:#dcfce7,stroke:#16a34a,color:#14532d
  class A,H input
  class C check
  class N,D,X,Y,M outcome
Loading

Blue: inputs. Amber: the exploration decision. Red/green: the loop before and after.

Evidence for the thresholds

  • The 0.25× threshold. These are explorable gemma attempts from 03:00 to 06:00Z, bucketed by each provider's latest measured decode rate against its chip-family median:

    bucket providers served first-chunk timeouts
    < 0.25× 17 45% 50%
    0.25–0.5× 23 83% 2.4%
    ≥ 0.5× 269 81% 1.2%

    The gate needs a median of ≥ 5 observations, not one, so it is stricter than this table.

  • Replay on the provider above. Using its own coordinator snapshots, the remembered-rate gate engages 22 min after its first slow observation and never clears. That would have blocked every one of its sampled explorations from 03:31Z on.

Validation

  • Registry tests (first_content_exploration_gate_test.go), through ReserveProviderEx:
  • API tests (first_content_exploration_outcome_test.go), through the real handleInferenceError → noteInferenceError glue:
    • deadline refusal and genuine fault count only when explored;
    • neutral terminal cause and capacity shed never count;
    • an explored first-content timeout counts and a non-explored one doesn't;
    • neither opens the node-health breaker;
    • a delivered exploration lifts a one-failure backoff.
  • Regression check: with the two predicate conditions removed, the suppression and remembered-slow tests fail (the degraded provider is selected).
  • fix(routing): explore idle providers without current first-content evidence #1254's tests pass unchanged, including TestFirstContentExplorationWaitsForServiceRetirement across scan, retained plan and commit race.
  • Suites: go test -race ./coordinator/registry ./coordinator/api, go vet ./coordinator/registry ./coordinator/api, make coordinator-test (33 packages).
  • Docs: make docs-impact-check BASE=origin/master passes. make docs-check fails locally only on a shallow clone with the libs/mlx-swift-lm submodule absent (pre-existing report and submodule links; none in files changed here). Docs changed: docs/architecture/first-content-routing.md, docs/architecture/routing.md, CHANGELOG.md.

For reviewers: the policy choices

  • Counting. deadline_unreachable and first-content timeouts count against exploration eligibility while staying neutral for health breakers. An explored attempt that ends in either produced no evidence.
  • Scope of feedback. Only explored attempts report back. A success served through the ordinary unknown fallback does not lower the backoff.
  • Numbers. 5 min / 2 h, 5-of-8 observations, 0.25× / 0.5×, and a 6 h TTL are policy bounds set from the evidence above, not measured optima.
  • What is not addressed. The provider-side cause is unknown. It is an M3 Max measuring about a tenth of its family's rates, with an unclassified slot state flapping about 12 times an hour. The breaker's blindness to idle-provider timeouts is deliberate and left unchanged.

Corrected 2026-09-30: an earlier revision of this description said the provider's engine reset every few minutes, from steps_executed returning to 0. That is normal per-interval reporting on 0.9.11 and 0.9.12. The fixture now uses a realistic 2,000 tok/s idle prefill rate instead of 20,000 (#1238).

Refs #1238, #1254.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Sep 30, 2026

Copy link
Copy Markdown

@brandon-eigenlabs is attempting to deploy a commit to the EigenLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 3e980ff80009 against base 41b83d26f2e9.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
Scan incomplete: one or more configured reviewers did not finish; completed reviewers' findings are shown below

Reviewers: anthropic/claude-opus-5.5: incomplete (review unavailable); openai/gpt-6-astra: incomplete (review unavailable)

Models: anthropic/claude-opus-5.5, openai/gpt-6-astra. Findings require human validation; this review never requests changes or blocks merging.

brandon-eigenlabs and others added 2 commits September 30, 2026 12:11
…tions

prices it at the fleet median. A provider whose engine keeps resetting
clears that evidence every few minutes, and a first-content timeout is a
429 the node-health breaker deliberately ignores. In production one such
provider (M3 Max decoding at ~11 tok/s against a ~79 fleet median) failed
most of the explorations it won for hours with no tracker reacting.

Two per-identity checks, scoped to exploration only:

- Outcome backoff. An attempt selected through exploration reports back:
  a first-content timeout, deadline refusal or genuine fault (the breaker's
  own fault test) doubles a per-model suppression interval (5 min to 2 h);
  a delivered request halves it. Reset-on-success would not stop a provider
  that still completes short requests.
- Remembered decode rate. Newly measured decode rates are kept per model
  across evidence resets and reconnects; a median of at least 5 below 0.25x
  the (model, chip family) fleet median makes the provider non-explorable.
  One slow observation never decides (the Layr-Labs#1238 lock-out); an observation
  at >= 0.5x clears the memory.

Both live on the stable-identity gate (merged on migration, swept after
6 h, cleared by a provider version change). Neither quarantines: a
suppressed provider still serves when nothing is feasible, and deadline
refusals and first-content timeouts stay neutral for every health breaker.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…aring rationale

The shared exploration fixture priced the idle provider at 20,000 tok/s
prefill, which no provider reports (Layr-Labs#1238 review). Use 2,000: still more
than a fast band ahead of the qualified peer's measured 1,200, so the
tests stay deterministic, and within the measured range.

Also correct the rationale in comments and docs. The degraded provider's
steps_executed returning to 0 is normal per-interval reporting on 0.9.11
and 0.9.12, not an engine reset. What makes exploration repeat is routine:
idle providers clear their decode evidence a few times an hour (fleet
median ~3/h on 0.9.11), so a slow provider is explorable again and again.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@brandon-eigenlabs
brandon-eigenlabs force-pushed the fix/first-content-exploration-backoff branch from 7188d96 to 3e980ff Compare September 30, 2026 19:12
davidtai added a commit that referenced this pull request Sep 30, 2026
Review of #1276 found that the median replaced a fresh own rate when the
other rate was undated. The evidence gap needs both measurements dated,
so the provider stayed admitted after a served request. On the explicit
path a cache-hit request renews decode but not isolated prefill. On the
legacy path the first EWMA after connect is undated by design. In both
cases the median kept the fresh value out of the cost.

Keep one admitted flag on the snapshot, and add the age of each dated
measurement. resolveEffectiveTPS uses the decode median only while the
provider's own decode evidence is missing or at least 5 minutes old.
resolvePrefillTPS does the same for isolated prefill. An undated value
counts as the provider's own evidence.

Do not note a TTFT calibration prediction when its cost used a median.

Docs: state the per-rate rule, the no-deadline behavior change, the
capacity_before_refusal case, the isolated-versus-observed prefill
difference, and the dependency on #1270 for a provider that is slow on
every request. Move the SetPrefillToDecodeRatio sentence back to the
fallback paragraph.

Refs #1238

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brandon-eigenlabs

Copy link
Copy Markdown
Contributor Author

Merge-order note with #1276 (median pricing for explored providers; review).

The two PRs compose. On a local merge only CHANGELOG.md conflicts. This PR's gates land in #1276's shared firstContentIdleEvidenceGap, so a backed-off or remembered-slow provider is neither explorable nor median-priced, and both test suites pass together.

#1276 should not land before this one. Priced at the median, a genuinely slow provider with stale evidence won 10 of 20 consecutive requests on #1276 alone, every one a timeout, and 1 of 20 with this PR merged in.

Follow-up if #1276 lands first: this PR tags an attempt as explored via firstContentEvidenceExplorable, which requires a performance reason. #1276 prices by provider state alone, so on no_deadline and vision requests a median-priced provider could fail without feeding the backoff. I'll switch the tag to "the winner was median-priced" once #1276 is on master.

davidtai added a commit that referenced this pull request Oct 4, 2026
Point the tps_prefill.go header at first_content_exploration_pricing.go, where
the pricing moved. State the #1270 known limit only in routing.md and rewrap
the first-content-routing.md paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gajesh2007

Copy link
Copy Markdown
Member

Superseded by #1371: #1371 . The replacement consolidates #1243, #1270 and #1276 on current master, preserves exploration backoff and remembered slow-rate safeguards, and credits @brandon-eigenlabs as the original author in both the PR description and signed commit co-author trailers. It also addresses the reviewed no-deadline/vision median-pricing feedback gap and prevents duplicate timeout/fault feedback. Combined local normal/race suites, schema checks, builds, lint and docs checks pass; hosted review/CI are now running on the replacement. Closing only to keep one review/merge target; thank you for the original contribution and cross-PR review.

@Gajesh2007 Gajesh2007 closed this Oct 7, 2026
Gajesh2007 added a commit that referenced this pull request Oct 7, 2026
…off (#1371)

* fix(routing): consolidate idle provider recovery and exploration backoff

Port the complementary fixes from #1243, #1270 and #1276 onto the
current domain-owned coordinator. Preserve independent decode aging,
per-rate exploration pricing, stable-identity suppression, and existing
physical admission and provider-health policy.

Close the integration gaps for median-priced deadline-exempt attempts,
duplicate timeout/fault feedback, reviewed-profile attribution, and
invalid explicit metadata replay. Retain the closed-loop starvation
regressions and add live-registry, outcome, identity and race coverage.

Original contributions: #1243 by JT Rose, #1270 by Brandon Curtis,
and #1276 by David Tai; earlier #1243 integration by jonathan308.

Co-authored-by: JT Rose <rosejt24@gmail.com>
Co-authored-by: Brandon Curtis <brandon@eigenlabs.org>
Co-authored-by: David Tai <dtaipublic@gmail.com>
Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(routing): preserve evidence identity across reconnects

Address the three Codex review findings on #1371: preserve newer healthy clears independently of outcome timestamps, distinguish explicitly missing rate evidence from legacy EWMAs, and deduplicate corroborating observations across reconnects and identity merges.

Bound producer watermarks and expiry fences, preserve healthy-only routing read fast paths, and add regression coverage for provenance replay, chronology, saturation, recovery and real reservation behavior. Original contribution attribution remains in the consolidation commit.

---------

Co-authored-by: JT Rose <rosejt24@gmail.com>
Co-authored-by: Brandon Curtis <brandon@eigenlabs.org>
Co-authored-by: David Tai <dtaipublic@gmail.com>
Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants